home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / XLisp 2.1e3 / Sources / macaboutbox.c < prev    next >
Text File  |  1993-11-13  |  3KB  |  127 lines

  1. /* macaboutbox.c - Display the "about box" of the application. */
  2. /* Written by Brian Kendig. */
  3. /* The functions here are only used by macint.c. */
  4.  
  5. #include <THINK.h>
  6. #include <Dialogs.h>
  7. #include <Fonts.h>
  8. #include <Menus.h>
  9. #include <Quickdraw.h>
  10. #include <Resources.h>
  11. #include <ToolUtils.h>
  12. #include <Traps.h>
  13. #include <Windows.h>
  14. #include "macint.h"
  15.  
  16. static DialogPtr aboutBox;
  17. extern Boolean hasColorQD;
  18.  
  19. static enum {
  20.     theOKButton        = 1,
  21.     theOKOutline    = 2,
  22.     theIcon            = 3,
  23.     theName            = 4,
  24.     theAboutText    = 5,
  25.     theCopyright    = 6
  26. } ;
  27.  
  28. pascal void DrawOKOutline (WindowPtr dialogWindow, short theItem) {
  29.     PenState    oldPen;
  30.     short        iType;
  31.     Handle        iHandle;
  32.     Rect        iRect;
  33.  
  34.       GetPenState (&oldPen);
  35.     PenNormal ();
  36.     PenSize (3,3);
  37.  
  38.     GetDItem (aboutBox, theOKButton, &iType, &iHandle, &iRect);
  39.       InsetRect (&iRect, -4, -4);
  40.     FrameRoundRect (&iRect, 16, 16);
  41.  
  42.     SetPenState (&oldPen);
  43. }
  44.  
  45. pascal void DrawIcon (WindowPtr dialogWindow, short theItem) {
  46.     short        iType;
  47.     Handle        iHandle;
  48.     Rect        iRect;
  49.  
  50.     GetDItem (aboutBox, theIcon, &iType, &iHandle, &iRect);
  51.     PlotIcon (&iRect, GetResource ('ICN#', 128));
  52. }
  53.  
  54. pascal void DrawName (WindowPtr dialogWindow, short theItem) {
  55.     short    iType;
  56.     Handle    iHandle;
  57.     Rect    iRect;
  58.     Str255    string;
  59.  
  60.     TextFont (helvetica);
  61.     TextSize (24);
  62.     TextFace (0);
  63.     GetDItem (aboutBox, theName, &iType, &iHandle, &iRect);
  64.     GetIndString (string, STRINGS_RES, 1);
  65.     TextBox (string+1, string[0], &iRect, teFlushLeft);
  66. }
  67.  
  68. pascal void DrawAboutText (WindowPtr dialogWindow, short theItem) {
  69.     short        iType;
  70.     Handle        iHandle;
  71.     Rect        iRect;
  72.     Str255        string;
  73.  
  74.     TextFont (monaco);
  75.     TextSize (9);
  76.     TextFace (0);
  77.     GetDItem (aboutBox, theAboutText, &iType, &iHandle, &iRect);
  78.     GetIndString (string, STRINGS_RES, 2);
  79.     TextBox (string+1, string[0], &iRect, teFlushLeft);
  80. }
  81.  
  82. pascal void DrawCopyright (WindowPtr dialogWindow, short theItem) {
  83.     short        iType;
  84.     Handle        iHandle;
  85.     Rect        iRect;
  86.     Str255        string;
  87.  
  88.     TextFont (systemFont);
  89.     TextSize (12);
  90.     TextFace (0);
  91.     GetDItem (aboutBox, theCopyright, &iType, &iHandle, &iRect);
  92.     GetIndString (string, STRINGS_RES, 3);
  93.     TextBox (string+1, string[0], &iRect, teFlushLeft);
  94. }
  95.  
  96. void DoAboutBox (void) {
  97.     short itemType, itemHit = 0;
  98.     Handle itemHandle;
  99.     Rect itemRect;
  100.  
  101.     aboutBox = GetNewDialog (ABOUT_BOX, NIL, (WindowPtr) -1);
  102.  
  103.     GetDItem (aboutBox, theOKOutline, &itemType, &itemHandle, &itemRect);
  104.     SetDItem (aboutBox, theOKOutline, itemType, (Handle) DrawOKOutline, &itemRect);
  105.  
  106.     GetDItem (aboutBox, theIcon, &itemType, &itemHandle, &itemRect);
  107.     SetDItem (aboutBox, theIcon, itemType, (Handle) DrawIcon, &itemRect);
  108.  
  109.     GetDItem (aboutBox, theName, &itemType, &itemHandle, &itemRect);
  110.     SetDItem (aboutBox, theName, itemType, (Handle) DrawName, &itemRect);
  111.  
  112.     GetDItem (aboutBox, theAboutText, &itemType, &itemHandle, &itemRect);
  113.     SetDItem (aboutBox, theAboutText, itemType, (Handle) DrawAboutText, &itemRect);
  114.  
  115.     GetDItem (aboutBox, theCopyright, &itemType, &itemHandle, &itemRect);
  116.     SetDItem (aboutBox, theCopyright, itemType, (Handle) DrawCopyright, &itemRect);
  117.  
  118.     ShowWindow (aboutBox);
  119.     
  120.     itemHit = 0;
  121.     while (itemHit != ok) ModalDialog (NIL, &itemHit);
  122.  
  123.     DisposDialog (aboutBox);
  124.  
  125. }
  126.  
  127.